<?php
	require("includes/basic.php");
	if(!isset($_SESSION['uid']))
	{
		header("location:authorise.php");
	}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
	<HEAD>
		<TITLE> :: <?php echo $appName?> :: </TITLE>
		<link rel='stylesheet' type='text/css' href='style/admin.css'>
		<script type='text/javascript' src='js/general.js'></script>
		<script type='text/javascript' src='js/help.js'></script>
		<script type='text/javascript' src='js/list.js'></script>
		<script type='text/javascript' src='js/jquery-latest.js'></script>
		<script type='text/javascript' src='jquery.livequery.js'></script>
		<style>
		 span.page_link a{color:#9c9c9c; font-size:13px;border:1px solid #9c9c9c;padding:5px;}
		 span.page_link a:hover{color:#CC3366;font-size:13px;}
		 .page_link a:active{color:#FF0084;font-size:13px;} 
		 </style>
		<script type='text/javascript'>
		$(document).ready(function()
		{
			$('#listSelectAll').live('click',function()
			{
				$('#viewtasks').find(':checkbox').attr('checked', this.checked);

			});

			$("#deactivate").click(function()
			{
				var pid=$(':checkbox:checked').val();
				var dataString = 'pid='+ pid;
				
				$.ajax
				({
					type: "POST",
					url: "deactivate.php",
					data: dataString,
					cache: false,
					success: function()
					{
					$("#projects").html(projects.php);
					} 
				});
			});

			$("#activate").click(function()
			{
				var pid=$(':checkbox:checked').val();
				var dataString = 'pid='+ pid;
				$.ajax
				({
					type: "POST",
					url: "activate.php",
					data: dataString,
					cache: false,
					success: function()
					{
						
					$("#projects").html(projects.php);
					} 
				});
			});

			$("#assign").click(function()
			{
				
				//var gtid=$(':checkbox:checked').val();
				var data = new Array();
				$("input[name='taskid']:checked").each(function(i) {
						data.push($(this).val());
				});
				var guid=$('#assignto').val();
				var pid = $('#projid').val();
				var sid = $('#phaseid').val();
				var mid = $('#modid').val();
				
				var dataString= 'gtid='+ data + '&guid='+ guid + '&pid='+ pid + '&sid=' + sid + '&mid=' + mid;
				$.ajax
				({
					type: "POST",
					url: "tasks.php",
					data: dataString,
					cache: false,
					success: function(html)
					{	
						$("#tasks").html(html);
					} 
				});
				if(gpid=="0")
				{
					alert("Select project");
				}
			});		
			$('#listSearchFilter').keyup(function(e) {
				
				//alert(e.keyCode);
				if(e.keyCode == 13) {
					var s=$('#listSearchFilter').val();				
					var pid = $('#projid').val();
					var sid = $('#phaseid').val();
					var mid = $('#modid').val();	
					
					var dataString= 's=' + s + '&pid='+ pid + '&sid=' + sid + '&mid=' + mid;
					$.ajax
					({
						type: "POST",
						url: "tasks.php",
						data: dataString,
						cache: false,
						success: function(html)
						{	
							$("#tasks").html(html);
						} 
					});
				}
			});
			$("#search").click(function()
			{
				
				var s=$('#listSearchFilter').val();				
				var pid = $('#projid').val();
				var sid = $('#phaseid').val();
				var mid = $('#modid').val();	
				
				var dataString= 's=' + s + '&pid='+ pid + '&sid=' + sid + '&mid=' + mid;
				$.ajax
				({
					type: "POST",
					url: "tasks.php",
					data: dataString,
					cache: false,
					success: function(html)
					{	
						$("#tasks").html(html);
					} 
				});
				
			});		
		});
		</script>
		<script type='text/javascript'>
			function bodyLoad() {
				setContext("This is the main administration view.");
				setActiveItemByName("/");
				loadingOff();
				try {
					document.getElementById('loaderContainerH').height = wHeight();
				} catch (e) {}
			}
			function bodyUnload() {
				loadingOn();
			}
		</script>
	</HEAD>

	<body onLoad='bodyLoad();' onUnload='bodyUnload();'>
		<?php $pageName="List of Tasks"; ?>
		<?php require("includes/header.php"); ?>

		<!-- devi : body content begins here -->

	<table border='0' cellspacing='0' cellpadding='0' id='loaderContainer' onClick='return false;'>
		<tr><td id='loaderContainerH'><div id='loader'>
			<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td>
				<p><img src='images/wait.gif' height='32' width='32' alt=''/>
				<strong>Please wait.<br>Loading ...</strong></p>
			</td></tr></table>
		</div></td></tr>
	</table>
	<?php if(isset($_SESSION['uid'])) {
	$projid=$_REQUEST['pid'];
	$phaseid=$_REQUEST['sid'];
	$moduleid=$_REQUEST['mid'];
	$tasks=mysql_query("select * from task_master where project_id=1 and phase_id=$phaseid and module_id=$moduleid");
	$projn=mysql_query("select * from project_master where project_id=$projid");
	$projr=mysql_fetch_array($projn);
	extract($projr);
	$projname=$projr['project_name'];
	$noOfTasks=mysql_num_rows($tasks);
	$sr=1;
	$class="evenrowbg";
	?>
	<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td id='screenH'>
		<div class='pathbar'><a href='index.php'>Admin</a> -> <a href='view-projects.php'>Projects</a> -> <a href='open-project.php?p=<?php echo $projid; ?>'><?php echo $projname; ?></a> -> Tasks</div>
		<div class='screenTitle'>
			<table width='100%' cellspacing='0'>
				<tr>
					<td>
						<?php echo $pageName;?>
					</td>		
				</tr>
			</table>
		</div>
<table class="dialog" cellpadding="0" cellspacing="0"><tr><td>
<table class="dialogbox" cellpadding="0" cellspacing="0">
<tr><td>

<!-- icons block area start -->
<div id='submenu'><span class="link" onClick="">&nbsp;&nbsp;<a href='#' style='white-space: nowrap;'><img src='images/add.png' alt='Add New Task' width='22' height='22' title='Add New Task'><a href='<?php echo "add-task.php?p=$projid&s=$phaseid&m=$moduleid"; ?>'>Add Task</a></a></span></div>
<!-- icons block area end -->
<div class="dialoghead" unselectable="on"></div><div class="dialogcontent" unselectable="on">
<!-- dialogcontent start -->

<div class='help' id='helpae' onMouseOut="hMH('ae');">Click here to edit the selected group.</div>
<div class='hide' id='confae'>null</div>
<div class='help' id='helpau' onMouseOut="hMH('au');">Click here to add or remove users to this group.</div>
<div class='hide' id='confau'>null</div>
<div class='help' id='helpaa' onMouseOut="hMH('aa');">Click here to activate the selected group.</div>
<div class='hide' id='confaa'>Are you sure you want to activate the selected group?</div>
<div class='help' id='helpac' onMouseOut="hMH('ac');">Click here to deactivate the selected group.</div>
<div class='hide' id='confac'>Are you sure you want to deactivate the selected group?</div>
<div class='help' id='helpad' onMouseOut="hMH('ad');">Click here to delete the selected group.</div>
<div class='hide' id='confad'>null</div>
<div class='help' id='helpde' onMouseOut="hMH('de');">Click here to edit the selected group.</div>
<div class='hide' id='confde'>null</div>
<div class='listArea'>
<!-- 3D block start -->
<fieldset class="dialogblock">
<legend><span class="textbold" unselectable="on">Tasks</span></legend>
		<table width='100%' cellspacing='0' cellpadding='0' border='0'>
			<tr><td>
			<table width='100%' cellspacing='0'>	
				<tr>
					<td align='left'>
						Total Task Count <?php echo $noOfTasks; ?>
					</td>
					<td class='misc'>&nbsp;
						
					</td>
				</tr>
			</table>
			<table width='100%' cellspacing='0' style='margin-bottom: 5px'>
		<tr>
			<td class='main'>
				<div>
					<input type='text' name='listSearchFilter' id='listSearchFilter' value='' size='20' maxlength='245' style='vertical-align: bottom;' >
					<span class="link" id='search'><img src='images/search.png' alt='Search' title='Search'>&nbsp;<a style='white-space: nowrap;'>Search</a></span>
					<div class='help' id='helpsearch'>Filters the list by Name.</div>
					&nbsp;&nbsp;	
				</div>
			</td>
			<td class='misc'>
				<div>
						<input type='hidden' name='projid' id='projid' value="<?php echo $projid; ?>">
						<input type='hidden' name='phaseid' id='phaseid' value="<?php echo $phaseid; ?>">
						<input type='hidden' name='modid' id='modid' value="<?php echo $moduleid; ?>">
						<span class="link" ><select name='assignto' id='assignto' style='width:190px;'><option value=''>--Assign Task--</option>
						<?php
						if($userType=='V')
						{
						
						$getresource=mysql_query("select * from user_master where vendor_id='$userId' and customer_id='$customerid' and user_name<>'admin@catseyetech.in'");
						}
						else
						{
						$getresource=mysql_query("select * from user_master where customer_id='$customerid' and user_name<>'admin@catseyetech.in'");
						}
						while($getresr=mysql_fetch_array($getresource))
						{
							$resid=$getresr['user_id'];
							$resname=$getresr['first_name']." ".$getresr['last_name'];
							echo "<option value='$resid'>$resname</option>";
						}
						?>
						</select><input type='submit' id='assign' value='Assign'></span>
			&nbsp;&nbsp;
						
						<!-- <span class="link" id='activate'><img src='images/multi_activate.png' alt='Activate' title='Activate'>&nbsp;<a href='#' style='white-space: nowrap;'>Activate</a></span>
			&nbsp;&nbsp;
						<span class="link" id='deactivate'><img src='images/multi_deactivate.png' alt='Deactivate' title='Deactivate'>&nbsp;<a style='white-space: nowrap;'>Deactivate</a></span> -->

				</div>
			</td>
				</tr>
			</table>
			<table width='100%'><tr><td id='tasks'>

			<?php include("tasks.php")?>
			</td></tr></table></td></tr>
		</table>
			
</fieldset>

<!-- 3D block end -->
</div>


<!-- dialogcontent end -->
</div>
<?php }else{echo "<div align='center'>You are not authorised to vies this page</div>";}?>
</td></tr></table>
</td></tr></table>
<p>&nbsp;</p>
	</td></tr></table>

		<!-- devi : body content ends here -->
		
		<?php
		if($noOfTasks < 8)
		{ ?>
			<style>
			.footer{
			position:absolute; bottom:0px;
		}
			</style>
		<?php
				}
		?>
		<?php require("includes/footer.php"); ?>
	</BODY>
</HTML>
